/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.uefs.cedoc.controle.fundo;

import br.uefs.cedoc.controle.Command;
import br.uefs.cedoc.controle.CommandException;
import br.uefs.cedoc.db.exception.DBConnectionException;
import br.uefs.cedoc.db.fundo.DBFundo;
import br.uefs.cedoc.entidades.FundoBean;
import java.sql.SQLException;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author Gregory Porto
 */

public class GetAllFundoCommand implements Command {
  private String next;

    public GetAllFundoCommand(String next) {
          this.next = next;
    }



    public String execute(HttpServletRequest req)
    throws CommandException {

        try {
            
            DBFundo dbfundo = new DBFundo();
            FundoBean[] fundos = dbfundo.listarFundos();
            req.setAttribute("fundo",fundos);
            
            FundoBean fundo = new FundoBean();
            for(int i=0;i<fundos.length;i++){
               fundo = fundos[i];
               System.out.println("Id = "+fundo.getIdFundo()+" Secao "+fundo.getFonte());
               //req.setAttribute("secao",secao);
            }
            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (DBConnectionException ex) {
                ex.printStackTrace();
            }  
            return next;
     
        } 
    }

